namespace Xmef.Engine
{
    using System;
    using System.Globalization;
    using System.Runtime.InteropServices;
    using Xmef.Interfaces;
    using Xmef.Library;

    [Serializable, StructLayout(LayoutKind.Sequential)]
    public struct PluginTypeInstance : IEquatable<PluginTypeInstance>
    {
        private IPluginIdentity _obj;
        private System.Type _type;
        public PluginTypeInstance(System.Type type, IPluginIdentity obj)
        {
            this._type = type;
            this._obj = obj;
        }

        public System.Type Type
        {
            get
            {
                return this._type;
            }
        }
        public bool Equals(PluginTypeInstance other)
        {
            return ((this._obj.Id == other._obj.Id) && (this._type == other._type));
        }

        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}", new object[] { TypeHelper.GetServiceName(this._type).ToString() });
        }

        public override bool Equals(object obj)
        {
            return (((obj is PluginTypeInstance) && (((PluginTypeInstance) obj)._obj.Id == this._obj.Id)) && (((PluginTypeInstance) obj)._type == this._type));
        }

        public override int GetHashCode()
        {
            return this._obj.Id;
        }
    }
}

